package com.gopay.common.cps.dao.ic.impl;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.ic.ReportDailyDtlDAO;
import com.gopay.common.domain.ic.ReportDailyDtl;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description 内部对账日报明细Dao实现
 * @Author jianghoupeng
 * @Date 2016/12/27 11:02
 *
 * Copyright (c) 2016. www.gopay.com.cn Inc.All rights reserved.
 */
@Repository("reportDailyDtlDAO")
public class ReportDailyDtlDAOImpl extends BaseDAOImpl<ReportDailyDtl, String> implements ReportDailyDtlDAO {

    @Override
    public ReportDailyDtl queryRDDtlByCondition(ReportDailyDtl dtl) {
        StringBuilder hql = new StringBuilder();
        Map param = new HashMap<>();
        param.put("checkDate", dtl.getCheckDate());
        param.put("tradeType", dtl.getTradeType());
        param.put("bizType", dtl.getBizType());
        hql.append(" from ReportDailyDtl where checkDate =:checkDate and tradeType =:tradeType and bizType=:bizType");
        List<ReportDailyDtl> list = this.findByHql(hql.toString(), param);
        if (list != null && list.size() == 1){
            return list.get(0);
        }
        return null;
    }
}
